import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { Tag } from 'ant-design-vue';

/**
 * authScopeOptions user也会用到
 */
export const authScopeOptions = [
  { color: 'green', label: '全部数据权限', value: '1' },
  { color: 'default', label: '自定数据权限', value: '2' },
  { color: 'orange', label: '本部门数据权限', value: '3' },
  { color: 'cyan', label: '本部门及以下数据权限', value: '4' },
  { color: 'error', label: '仅本人数据权限', value: '5' },
  { color: 'default', label: '部门及以下或本人数据权限', value: '6' },
];

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'roleName',
    label: '角色名称',
  },
];

export const columns: VxeGridProps['columns'] = [
  {
    title: '角色名称',
    field: 'roleName',
  },
  {
    title: '角色code',
    field: 'roleCode',
    slots: {
      default: ({ row }) => {
        return <Tag color="processing">{row.roleCode}</Tag>;
      },
    },
  },
  {
    title: '创建人',
    field: 'creator',
  },
  {
    title: '创建时间',
    field: 'gmtCreated',
  },
  {
    title: '更新人',
    field: 'modifier',
  },
  {
    title: '更新时间',
    field: 'gmtModified',
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    resizable: false,
    width: 'auto',
  },
];

export const drawerSchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'roleName',
    label: '角色名称',
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'roleCode',
    help: '如: simpleUser等',
    label: '角色code',
    rules: 'required',
  },
];

export const authDrawerSchemas: FormSchemaGetter = () => [
  {
    component: 'Input',
    defaultValue: [],
    fieldName: 'menuIdList',
    label: '菜单权限',
    formItemClass: 'col-span-2',
  },
  {
    component: 'CheckboxGroup',
    componentProps: {
      options: [],
    },
    fieldName: 'resourceIdList',
    label: '按钮权限',
  },
];
